from selenium.webdriver.common.by import By

from Base.Base import Base


class Login_Page(Base):
    #输入账号
    loc_username=(By.XPATH,'//*[@id="app"]/div/div/form/div[1]/div/div/input')
    #输入密码
    loc_password = (By.XPATH, '//*[@id="app"]/div/div/form/div[2]/div/div/input')
    #点击登录
    loc_login=(By.CLASS_NAME,'el-button')

    def username(self,username):
        """
        输入账号
        :param username:
        :return:
        """
        self.send_keys(self.loc_username,username)

    def password(self,password):
        """
        输入密码
        :param password:
        :return:
        """
        self.send_keys(self.loc_password,password)
    def login(self):
        """
        点击登录
        :return:
        """
        self.click(self.loc_login)

    def test_login(self,username,password):
        self.open_url('http://10.59.9.21/dist#/login')
        self.username(username)
        self.password(password)
        self.login()